package Listeners;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import FileIO.FileManager;
import Model.ConferenceManager;

/**
 * WindowListener used for the ConferenceWizardFrame.
 * 
 * Allows all current system data to be store to File
 * so that it can be used for future use of the application.
 * 
 * @author Paul Schultz (ps87@uw.edu)
 * @version 11/28/2012
 */
public class CWFrameListener implements WindowListener
{
  private ConferenceManager my_manager;
  
  public CWFrameListener(ConferenceManager the_manager)
  {
    my_manager = the_manager;
  }

  @Override
  public void windowActivated(WindowEvent arg0)
  {
    // do nothing
  }

  @Override
  public void windowClosed(WindowEvent arg0)
  {
    // do nothing
  }

  /**
   * Writes the current state of the program
   * to file so the data will be saved for
   * further use of the program.
   */
  @Override
  public void windowClosing(WindowEvent arg0)
  {
    //Debugging statement
    //System.out.println(arg0.toString() + " Saving Data...");
    FileManager.saveUsers(my_manager.getUsers());
    FileManager.saveConferences(my_manager.getConferences());
  }

  @Override
  public void windowDeactivated(WindowEvent arg0)
  {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void windowDeiconified(WindowEvent arg0)
  {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void windowIconified(WindowEvent arg0)
  {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void windowOpened(WindowEvent arg0)
  {
    // TODO Auto-generated method stub
    
  }

}
